import CircularJSON from 'circular-json'

const state = {
    breadCrumbList: localStorage.getItem('breadCrumb') || '[]',
    allRouter: sessionStorage.getItem('allRounter') || '[]'
}

const mutations = {
    SET_BREADCRUMB: (state, data) => {
        const breadcrumbList = []
        for (const route of data) {
            const {fullPath, meta, name, params, path, query} = route;
            breadcrumbList.push({fullPath, meta, name, params, path, query});
        }
        state.breadCrumbList = JSON.stringify(breadcrumbList)
        localStorage.setItem('breadCrumb', JSON.stringify(breadcrumbList))
    },
    SET_ALLROUTER: (state, data) => {
        state.allRouter = JSON.stringify(data)
        sessionStorage.setItem('allRounter', JSON.stringify(data))
    },
}

const actions = {}

export default{
    namespaced: true,
    state,
    mutations,
    actions
}